<template>
  <div style="overflow-y: hidden; overflow-x: hidden; height: 100%">
    <div class="block text-center" m="t-4">
      <!-- 轮播图 -->
      <el-carousel trigger="click" height="460px">
        <el-carousel-item v-for="item in bannerUrl" :key="item">
          <img :src="item" alt="" style="height: 460px" />
        </el-carousel-item>
      </el-carousel>
    </div>
    <!-- 手机模块 -->
    <div class="phone">
      <p class="title">手机</p>
      <div class="imgMain">
        <div class="phoneImg">
          <img
            src="http://101.132.181.9:3000/public/imgs/phone/phone.png"
            alt=""
          />
        </div>
        <!-- 手机模块的产品展示 -->
        <div class="phoneList">
          <ul class="phoneListOne">
            <li class="listView" v-for="item in this.listOne" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 500 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
          <ul class="phoneListTwo">
            <li class="listView" v-for="item in this.listTwo" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 100 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <!-- 手机模块 -->
    <div class="phone">
      <p class="title">手机</p>
      <div class="imgMain">
        <div class="phoneImg">
          <img
            src="http://101.132.181.9:3000/public/imgs/phone/phone.png"
            alt=""
          />
        </div>
        <!-- 手机模块的产品展示 -->
        <div class="phoneList">
          <ul class="phoneListOne">
            <li class="listView" v-for="item in this.listOne" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 500 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
          <ul class="phoneListTwo">
            <li class="listView" v-for="item in this.listTwo" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 100 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <!-- 手机模块 -->
    <div class="phone">
      <p class="title">手机</p>
      <div class="imgMain">
        <div class="phoneImg">
          <img
            src="http://101.132.181.9:3000/public/imgs/phone/phone.png"
            alt=""
          />
        </div>
        <!-- 手机模块的产品展示 -->
        <div class="phoneList">
          <ul class="phoneListOne">
            <li class="listView" v-for="item in this.listOne" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 500 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
          <ul class="phoneListTwo">
            <li class="listView" v-for="item in this.listTwo" :key="item.proid">
              <router-link
                :to="{ name: 'orders' }"
                custom
                v-slot="{ navigate, isActive }"
              >
                <span
                  :class="[isActive && 'router-link-active']"
                  @click="navigate"
                >
                  <img :src="item.img1" alt="" />
                  <h4>{{ item.brand }}</h4>
                  <p>{{ item.proname }}</p>
                  <span class="cheap">{{ item.originprice - 100 }}元</span>
                  <span class="expensive">{{ item.originprice }}元</span>
                </span>
              </router-link>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { getProjectList } from '@/api/production'

export default {
  data() {
    return {
      listOne: '',
      listTwo: ''
    }
  },
  created() {
    getProjectList().then((res) => {
      // console.log(res.data)
      this.listOne = res.data.slice(0, 4)
      this.listTwo = res.data.slice(4, 8)
      // console.log(this.listOne, this.listTwo)
    })
  },
  methods: {},
  components: {},
  computed: {
    ...mapState(['bannerUrl'])
  }
}
</script>

<style scoped lang="scss">
.orders-link {
  text-decoration: none;
}
// 手机模块css
.phone {
  height: 800px;
  background: rgb(235, 234, 234);
  .title {
    font-size: 24px;
    padding-top: 10px;
    padding-left: 10px;
    height: 20px;
  }
  .imgMain {
    position: relative;
    height: 750px;
    .phoneImg {
      width: 268px;
      height: 614px;
    }
    // 产品展示
    .phoneList {
      position: absolute;
      top: -16px;
      right: 0;
      height: 703px;
      width: 908px;

      ul {
        padding-left: 18px;
        width: 100%;
        height: 343px;
        img {
          margin: 25px;
          width: 160px;
          height: 160px;
        }
      }
      // 产品展示第一行
      .phoneListOne {
        list-style: none;
        display: flex;
        justify-content: space-between;
        flex: 1;
        // 划入效果等
        .listView:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
        .listView {
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 213px;
          float: right;
          background: #fff;
          position: relative;
          // 产品内容
          h4 {
            margin: 0;
            text-align: center;
          }
          p {
            font-size: 13px;
            text-align: center;
          }
          .expensive {
            color: rgb(153, 149, 149);
            text-decoration: line-through;
            position: absolute;
            bottom: 20px;
            left: 50%;
          }
          .cheap {
            color: #ff6700;
            position: absolute;
            bottom: 20px;
            left: 20%;
          }
        }
      }
      // 产品展示第二行
      .phoneListTwo {
        list-style: none;
        display: flex;
        justify-content: space-between;
        flex: 1;
        margin-top: 17px;
        // 划入效果等
        .listView:hover {
          z-index: 2;
          -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
          -webkit-transform: translate3d(0, -2px, 0);
          transform: translate3d(0, -2px, 0);
        }
        .listView {
          -webkit-transition: all 0.2s linear;
          transition: all 0.2s linear;
          width: 213px;
          float: right;
          background: #fff;
          position: relative;
          // 产品内容
          h4 {
            margin: 0;
            text-align: center;
          }
          p {
            font-size: 13px;
            text-align: center;
          }
          .expensive {
            color: rgb(153, 149, 149);
            text-decoration: line-through;
            position: absolute;
            bottom: 20px;
            left: 50%;
          }
          .cheap {
            color: #ff6700;
            position: absolute;
            bottom: 20px;
            left: 20%;
          }
        }
      }
    }
  }
}
</style>
